﻿using Bootstrap.Definition.Enums;
using Bootstrap.Helper;
using Bootstrap.Template.Image;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Bootstrap.Control
{
    [ToolboxData("<{0}:BootstrapDropDown runat=server></{0}:BootstrapDropDown>")]
    public class BootstrapImage : WebControl
    {
        #region Properties

        public ImageTypeEnum ImageType { get; set; }

        public string ImageSource { get; set; }

        public string Alt { get; set; }

        #endregion

        #region Methods

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            string imageSrc = this.ImageSource;

            BootstrapImageTemplate template = new BootstrapImageTemplate();

            template.ImageSource = ValueHelper.GetDefaultValue<string>(imageSrc, WebConfigurationManager.AppSettings["EmptyImageSrc"]);
            template.Alt = ValueHelper.GetDefaultValue<string>(this.Alt, string.Empty);
            template.ImageType = this.ImageType;

            writer.Write(template.TransformText());
        }

        #endregion
    }
}
